package dialogs;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.newxlmedical.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import custom.MyDialog;

/**
 * Created by Administrator on 2018/7/6.
 */

public class GoodsDetialsDialog extends MyDialog {
    @BindView(R.id.tv_dialog_goods_detial1)
    TextView tv1;
    @BindView(R.id.tv_dialog_goods_detial2)
    TextView tv2;
    @BindView(R.id.tv_dialog_goods_detial3)
    TextView tv3;
    @BindView(R.id.tv_dialog_goods_detial4)
    TextView tv4;
    @BindView(R.id.tv_dialog_goods_detial5)
    TextView tv5;
    @BindView(R.id.tv_dialog_goods_detial6)
    TextView tv6;
    @BindView(R.id.tv_dialog_goods_detial_close)
    ImageView ivClose;
    @BindView(R.id.ll_dialog_goods_detial6)
    LinearLayout ll6;
    @BindView(R.id.tv_dialog_goods_detial7)
    TextView tv7;
    @BindView(R.id.tv_dialog_goods_detial8)
    TextView tv8;
    @BindView(R.id.ll_dialog_goods_detial8)
    LinearLayout ll8;

    private String[] content;

    public GoodsDetialsDialog(@NonNull Context context, int themeResId, String[] content) {
        super(context, themeResId);
        this.content = content;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_goods_detial);
        ButterKnife.bind(this);
        //设置不可取消，点击其他区域不能取消
        setCancelable(true);
        setCanceledOnTouchOutside(true);

        if (!content[0].equals("")) {
            tv1.setText(content[0]);
        }
        if (!content[1].equals("")) {
            Log.e("TAG", "content[1]");
            tv2.setText(content[1]);
        }
        if (!content[2].equals("")) {
            tv3.setText(content[2]);
        }

        if (!content[3].equals("")) {
            tv4.setText(content[3]);
        }
        if (!content[4].equals("")) {
            tv5.setText(content[4]);
        }

        if (content[5].equals("")) {
            ll6.setVisibility(View.GONE);
        } else {
            tv6.setText(content[5]);
        }

        if (content[6].equals("")) {
            tv7.setVisibility(View.GONE);
        }else {
            tv7.setText(content[6]);
        }

        if (content[7].equals("")){
            ll8.setVisibility(View.GONE);
        }else {
            tv8.setText(content[7]);
        }

    }

    @OnClick(R.id.tv_dialog_goods_detial_close)
    public void onViewClicked() {
        dismiss();
    }

}
